package es.itpyme.websip.util;

import java.util.logging.Logger;

public class LogUtil {
	
	private static final String METHOD_BEGIN="begin";
	private static final String METHOD_END="end";
	
	

	public static void debug(Logger log,String methodName,String data){
//		log.debug(new StringBuffer(methodName).append("( ").append(data).append(")").toString());
	}
	
	public static void debug(Logger log,String data){
//		log.debug(new StringBuffer(getMethodName(1)).append("( ").append(data).append(")").toString());
	}
	
	public static void debugIni(Logger log,String methodName){
//		log.debug(new StringBuffer(methodName).append("( ").append(METHOD_BEGIN).append(")").toString());
	}
	
	
	public static void debugFin(Logger log,String methodName){
//		log.debug(new StringBuffer(methodName).append("( ").append(METHOD_END).append(")").toString());
	}
	
	public static void debugIni(Logger log){
//		log.debug(new StringBuffer(getMethodName(1)).append("( ").append(METHOD_BEGIN).append(")").toString());
	}
	
	
	public static void debugFin(Logger log){
//		log.debug(new StringBuffer(getMethodName(1)).append("( ").append(METHOD_END).append(")").toString());
	}
	
	/**
	 * Get the method name for a depth in call stack. <br />
	 * Utility function
	 * @param depth depth in the call stack (0 means current method, 1 means call method, ...)
	 * @return method name
	 */
	public static String getMethodName(final int depth)
	{
	  final StackTraceElement[] ste = Thread.currentThread().getStackTrace();

	  //System. out.println(ste[ste.length-depth].getClassName()+"#"+ste[ste.length-depth].getMethodName());
	  // return ste[ste.length - depth].getMethodName();  //Wrong, fails for depth = 0
	  return ste[2+ depth].getMethodName(); //Thank you Tom Tresansky
	}

}
